package com.trkj.service;

import com.trkj.dao.accountDao;
import com.trkj.entity.Account;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Data
@Service
public class accountServiceImpl implements accountService{
    @Resource
    private accountDao accountDao;
    @Override
    @Transactional
    public int insertAccount(Account act) {
        int count= accountDao.insertAccount(act);
        log.debug("完成插入{}",act);
        return count;
    }

    public int updateMM(int accountId, String newPassword, String oldPassword){
        int count=accountDao.updatePassword(accountId,newPassword,oldPassword);
        if(count==0){
            log.debug("修改失败,旧密码错误");
        }else{
            log.debug("修改成功");
        }
        return count;
    }
    public int updateJe(int id1,int id2,double je,String pass,String type){
        int count=accountDao.updateYE(id1,id2,je,pass,type);
        if(count==0){
            log.debug("转账失败");
        }else{
            log.debug("成功");
        }
        return count;
    }
    public boolean dui(){
        boolean x=accountDao.dui();
        return x;
    }
    public List<Map<String,Object>> selectZh(int id){
        List<Map<String,Object>> list=  accountDao.selectZh(id);
        return list;
    }
}
